using System;
using System.Collections.Generic;
using System.Text;

namespace tKitchen
{
    public class IngredientPresenter
    {
        tKitchenMain domain;
        IngredientInput inputForm;

        public IngredientPresenter(tKitchenMain domainIn)
        {
            domain = domainIn;
            inputForm = new IngredientInput(this);

            PopulateGrid();
            
        }

        internal void AddIngredient(string nameIn, string descrIn)
        {
            Ingredient temp = new Ingredient();
            temp.Name = nameIn;
            temp.Descr = descrIn;

            domain.AddObject(temp);

            PopulateGrid();

        }

        internal void UpdateIngredient(Ingredient temp)
        {
            domain.UpdateObject(temp);
            inputForm.RefreshGrid();
        }


        private void PopulateGrid()
        {
            List<Ingredient> list = domain.GetIngredientList();
            inputForm.SetDataSource(list);
            inputForm.RefreshGrid();
        }


        internal void ShowForm()
        {
            inputForm.Show();
        }
    }
}
